test(api): fix flaky build-tag tests by waiting for terminal build status#1200
Open
l2ysho wants to merge 2 commits into
Open
test(api): fix flaky build-tag tests by waiting for terminal build status#1200l2ysho wants to merge 2 commits into
l2ysho wants to merge 2 commits into
Conversation
…atus waitForBuildToFinish returned as soon as the build status was anything other than RUNNING. A freshly-created build starts in READY (queued) before transitioning to RUNNING, so the helper returned immediately with a not-yet-finished build. By the time the build-tag assertions ran, the build was RUNNING and tagging failed with "only successful builds can be tagged". Replace the hand-rolled poll loop with the client's built-in waitForFinish(), which waits for a terminal status and polls server-side. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
waitForFinish() returns Promise<Build>, so waitForBuildToFinish no longer needs the async keyword and its call sites no longer need ! assertions. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Replace the hand-rolled poll loop in
waitForBuildToFinish(test setup helper) with the apify-client's built-inwaitForFinish().Why
The build-tag API tests (
test/api/commands/builds/tags.test.ts) flake intermittently — e.g. run #27580124989:Root cause
waitForBuildToFinishreturned as soon as the status was anything other thanRUNNING:A freshly-created build starts in
READY(queued) and only then transitionsRUNNING→SUCCEEDED. SinceREADY !== RUNNING, the helper returned immediately with a build that hadn't started yet. By the time theadd-tagassertions ran, the build had moved toRUNNING, so tagging failed with "only successful builds can be tagged" — and the dependent "already tagged" assertion cascaded from the same broken setup.How
client.build(buildId).waitForFinish()waits for a terminal status and polls server-side, removing the magic 2.5s interval and the early-return bug. The existing!assertions andwaitForFinishWithTimeoutwrapper are unaffected.Testing
pnpm run lint(type-aware)pnpm run formatpnpm run buildAPI Testswill validate the live behavior.🤖 Generated with Claude Code